/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import core.AEntityContentProvider;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ivan
 */
@Entity
@Table(name = "DISCIPLINE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Discipline.findAll", query = "SELECT d FROM Discipline d"),
    @NamedQuery(name = "Discipline.findByDisciplineId", query = "SELECT d FROM Discipline d WHERE d.disciplineId = :disciplineId"),
    @NamedQuery(name = "Discipline.findByName", query = "SELECT d FROM Discipline d WHERE d.name = :name"),
    @NamedQuery(name = "Discipline.findByRules", query = "SELECT d FROM Discipline d WHERE d.rules = :rules")})
public class Discipline extends AEntityContentProvider<Discipline> implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @GeneratedValue(generator="CommonSeq", strategy= GenerationType.SEQUENCE)
 //   @SequenceGenerator( name="CommonSeq",sequenceName="common_seq", allocationSize=1)
    @Column(name = "DISCIPLINE_ID")
    private BigDecimal disciplineId;
    @Size(max = 25)
    @Column(name = "NAME")
    private String name;
    @Size(max = 100)
    @Column(name = "RULES")
    private String rules;
    @OneToMany(mappedBy = "disciplineId")
    private Set<League> leagueSet;
    @OneToMany(mappedBy = "disciplineId")
    private Set<Team> teamSet;

    public Discipline() {
    }

    public Discipline(BigDecimal disciplineId) {
        super(Discipline.class);
        this.disciplineId = disciplineId;
    }

    public BigDecimal getDisciplineId() {
        return disciplineId;
    }

    public void setDisciplineId(BigDecimal disciplineId) {
        this.disciplineId = disciplineId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRules() {
        return rules;
    }

    public void setRules(String rules) {
        this.rules = rules;
    }

    @XmlTransient
    public Set<League> getLeagueSet() {
        return leagueSet;
    }

    public void setLeagueSet(Set<League> leagueSet) {
        this.leagueSet = leagueSet;
    }

    @XmlTransient
    public Set<Team> getTeamSet() {
        return teamSet;
    }

    public void setTeamSet(Set<Team> teamSet) {
        this.teamSet = teamSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (disciplineId != null ? disciplineId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Discipline)) {
            return false;
        }
        Discipline other = (Discipline) object;
        if ((this.disciplineId == null && other.disciplineId != null) || (this.disciplineId != null && !this.disciplineId.equals(other.disciplineId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Discipline[ disciplineId=" + disciplineId + " ]";
    }
    
}
